home *** CD-ROM | disk | FTP | other *** search
- package java.io;
-
- import java.nio.charset.Charset;
- import java.util.Arrays;
- import java.util.Formatter;
- import sun.misc.SharedSecrets;
- import sun.nio.cs.StreamDecoder;
- import sun.nio.cs.StreamEncoder;
-
- public final class Console implements Flushable {
- private Object readLock;
- private Object writeLock;
- private Reader reader;
- private Writer out;
- // $FF: renamed from: pw java.io.PrintWriter
- private PrintWriter field_0;
- private Formatter formatter;
- // $FF: renamed from: cs java.nio.charset.Charset
- private Charset field_1;
- private char[] rcb;
- private static boolean echoOff;
- private static Console cons;
-
- public PrintWriter writer() {
- return this.field_0;
- }
-
- public Reader reader() {
- return this.reader;
- }
-
- public Console format(String var1, Object... var2) {
- this.formatter.format(var1, var2).flush();
- return this;
- }
-
- public Console printf(String var1, Object... var2) {
- return this.format(var1, var2);
- }
-
- public String readLine(String var1, Object... var2) {
- String var3 = null;
- synchronized(this.writeLock) {
- synchronized(this.readLock) {
- if (var1.length() != 0) {
- this.field_0.format(var1, var2);
- }
-
- try {
- char[] var6 = this.readline(false);
- if (var6 != null) {
- var3 = new String(var6);
- }
- } catch (IOException var9) {
- throw new IOError(var9);
- }
- }
-
- return var3;
- }
- }
-
- public String readLine() {
- return this.readLine("");
- }
-
- public char[] readPassword(String var1, Object... var2) {
- Object var3 = null;
- synchronized(this.writeLock) {
- char[] var22;
- synchronized(this.readLock) {
- if (var1.length() != 0) {
- this.field_0.format(var1, var2);
- }
-
- try {
- echoOff = echo(false);
- var22 = this.readline(true);
- } catch (IOException var18) {
- throw new IOError(var18);
- } finally {
- try {
- echoOff = echo(true);
- } catch (IOException var17) {
- }
-
- }
-
- this.field_0.println();
- }
-
- return var22;
- }
- }
-
- public char[] readPassword() {
- return this.readPassword("");
- }
-
- public void flush() {
- this.field_0.flush();
- }
-
- private static native String encoding();
-
- private static native boolean echo(boolean var0) throws IOException;
-
- private char[] readline(boolean var1) throws IOException {
- int var2 = this.reader.read(this.rcb, 0, this.rcb.length);
- if (var2 < 0) {
- return null;
- } else {
- if (this.rcb[var2 - 1] == '\r') {
- --var2;
- } else if (this.rcb[var2 - 1] == '\n') {
- --var2;
- if (var2 > 0 && this.rcb[var2 - 1] == '\r') {
- --var2;
- }
- }
-
- char[] var3 = new char[var2];
- if (var2 > 0) {
- System.arraycopy(this.rcb, 0, var3, 0, var2);
- if (var1) {
- Arrays.fill(this.rcb, 0, var2, ' ');
- }
- }
-
- return var3;
- }
- }
-
- private char[] grow() {
- assert Thread.holdsLock(this.readLock);
-
- char[] var1 = new char[this.rcb.length * 2];
- System.arraycopy(this.rcb, 0, var1, 0, this.rcb.length);
- this.rcb = var1;
- return this.rcb;
- }
-
- private static native boolean istty();
-
- private Console() {
- this.readLock = new Object();
- this.writeLock = new Object();
- String var1 = encoding();
- if (var1 != null) {
- try {
- this.field_1 = Charset.forName(var1);
- } catch (Exception var3) {
- }
- }
-
- if (this.field_1 == null) {
- this.field_1 = Charset.defaultCharset();
- }
-
- this.out = StreamEncoder.forOutputStreamWriter(new FileOutputStream(FileDescriptor.out), this.writeLock, this.field_1);
- this.field_0 = new 2(this, this.out, true);
- this.formatter = new Formatter(this.out);
- this.reader = new LineReader(this, StreamDecoder.forInputStreamReader(new FileInputStream(FileDescriptor.in), this.readLock, this.field_1));
- this.rcb = new char[1024];
- }
-
- // $FF: synthetic method
- static Object access$000(Console var0) {
- return var0.readLock;
- }
-
- // $FF: synthetic method
- static char[] access$100(Console var0) {
- return var0.rcb;
- }
-
- // $FF: synthetic method
- static char[] access$200(Console var0) {
- return var0.grow();
- }
-
- // $FF: synthetic method
- static boolean access$300() {
- return istty();
- }
-
- // $FF: synthetic method
- static Console access$400() {
- return cons;
- }
-
- // $FF: synthetic method
- static Console access$402(Console var0) {
- cons = var0;
- return var0;
- }
-
- // $FF: synthetic method
- Console(1 var1) {
- this();
- }
-
- // $FF: synthetic method
- static boolean access$600() {
- return echoOff;
- }
-
- // $FF: synthetic method
- static boolean access$700(boolean var0) throws IOException {
- return echo(var0);
- }
-
- // $FF: synthetic method
- static Charset access$800(Console var0) {
- return var0.field_1;
- }
-
- static {
- SharedSecrets.setJavaIOAccess(new 1());
- }
- }
-